//创建一个路由器，并暴露出去

//第一步：引入createRouter
import { createRouter,createWebHistory } from "vue-router"

import Home from '@/pages/Home.vue'
import News from "@/pages/News.vue"
import About from "@/pages/About.vue"
import Detail from "@/pages/Detail.vue"

//第二步：创建路由器
const router = createRouter({
        history:createWebHistory(),
        routes: [
                {
                        path: '/home',
                        component: Home
                },
                {
                        path:'/news',
                        component: News,
                        children:[
                            {
                                name:'xiang',
                                path:'detail',
                                component:Detail,
                                //第一种写法：将路由收到的所有params参数作为props传给路由组件
                                //path:'detail/:id/:content/:author'
                                // props: true
                                //第二种写法：可以自己决定将什么作为props给路由组件。
                                props(route) {
                                        return route.query
                                },
                                
                            }   
                        ]
                },
                {
                        path:'/abouts',
                        component: About
                },
                {
                  path:'/',
                  redirect:'/home' 
                }
        ]
})

export default router